package com.gancp.vo;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;


/**
 * @Author gancp
 * @Date 时间被黑洞吸走了
 * @Descripition 自定义用户session数据
 **/
@Data
public class UserSessionVo {

    private String userId;

    private String mobile;

    private String token;

    private String platform;

    private String loginTimeStr;

    private String pushUserId;

    private String pushChannelId;

    public Map<String, String> toMap() {
        Map<String, String> map = new HashMap();
        map.put( "userId", userId );
        map.put( "mobile", mobile );
        map.put( "token", token );
        map.put( "platform", platform );
        map.put( "loginTime", loginTimeStr );
        if (StringUtils.isNoneBlank( pushUserId )) {
            map.put( "pushUserId", pushUserId );
        }
        if (StringUtils.isNoneBlank()) {
            map.put( "pushChannelId", pushChannelId );
        }
        return map;
    }

    public static UserSessionVo transform(Map<String, String> map) {
        UserSessionVo userSessionVo = new UserSessionVo();
        userSessionVo.setUserId( map.get( "userId" ) );
        userSessionVo.setPlatform( map.get( "platform" ) );
        userSessionVo.setMobile( map.get( "mobile" ) );
        userSessionVo.setToken( map.get( "token" ) );
        userSessionVo.setPushUserId( map.get( "pushUserId" ) );
        userSessionVo.setPushChannelId( map.get( "pushChannelId" ) );
        return userSessionVo;
    }


}
